import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
    },
    {
      path: '/skill',
      name: 'skill',
      component: () => import('../views/Skill.vue'),
    },
    {
      path: '/work',
      name: 'work',
      component: () => import('../views/Work.vue'),
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/About.vue'),
    },
    {
      path: '/contactMe',
      name: 'contactMe',
      component: () => import('../views/ContactMe.vue'),
    },
    {
      path: '/:pathMatch(.*)*',
      name: '404',
      component: () => import('../views/404.vue'),
    },
  ],
})

// 全局前置守卫
router.beforeEach((to, from, next) => {
  // console.log("去", to.path,"来自", from.path);
  next()
})

export default router
